#pragma once

// Xerces
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/sax/HandlerBase.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/PlatformUtils.hpp>

/**
  * Simple class used for easy (though not terribly efficient)
  * transcoding of XMLCh data to local code page for display.
  */
class StrX
{
public :
	StrX( const XMLCh *toTranscode )
	{
		mLocalForm = XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode( toTranscode );
	}
	~StrX( void )
	{
		XERCES_CPP_NAMESPACE_QUALIFIER XMLString::release( &mLocalForm );
	}

	std::string LocalForm( void ) const { return mLocalForm; }

	operator const std::string () const { return mLocalForm; }
	operator std::string () { return mLocalForm; }
	friend std::ostream &operator << (std::ostream &target, const StrX &toDump)
	{
		target << toDump.LocalForm();
		return target;
	}
private :
	char *mLocalForm;
};

/**
  *	Simple class for easy (though not terribly efficient)
  * transcoding of char *data to XMLCh data.
  */
class XStr
{
public :
	XStr( const char *toTranscode )
	{
		mUnicodeForm = XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode( toTranscode );
	}
	XStr( const std::string &toTranscode )
	{
		mUnicodeForm = XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode( toTranscode.c_str() );
	}
	~XStr( void )
	{
		XERCES_CPP_NAMESPACE_QUALIFIER XMLString::release( &mUnicodeForm );
	}

	const XMLCh *UnicodeForm( void ) const { return mUnicodeForm; }

	operator const XMLCh * () const { return mUnicodeForm; }
	operator XMLCh * () { return mUnicodeForm; }

private :
	XMLCh *mUnicodeForm;
};